package com.alibaba.cloud.base.business.dict.controller;

import com.alibaba.cloud.base.business.dict.domain.BasDictType;
import com.alibaba.cloud.base.business.dict.service.BasDictTypeService;
import com.alibaba.framework.aop.log.LogWrite;
import com.alibaba.framework.domain.ResponseWrapper;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "基础字典类型")
@RestController
@RequestMapping("/dictType")
public class BasDictTypeController {

    private static final Logger LOGGER = LoggerFactory.getLogger(BasDictTypeController.class);

    @Resource
    private BasDictTypeService basDictTypeService;

    @LogWrite(value = "查询字典类型列表")
    @GetMapping("/getAll")
    public ResponseWrapper getAll() {

        List<BasDictType> basDictTypeList = basDictTypeService.getAll();
        return ResponseWrapper.Success(basDictTypeList);
    }

    @LogWrite(value = "根据字典类型查询类型列表")
    @GetMapping("/getDictTypeListByType")
    public ResponseWrapper getDictTypeListByType(@RequestParam("typeCode") String typeCode) {

        List<BasDictType> basDictTypeList = basDictTypeService.getDictTypeListByType(typeCode);
        return ResponseWrapper.Success(basDictTypeList);
    }

    @LogWrite(value = "新增医嘱项目")
    @PostMapping("/save")
    public ResponseWrapper save(@RequestBody BasDictType basDictType) {

        basDictTypeService.save(basDictType);
        return ResponseWrapper.Success();
    }

    @LogWrite(value = "修改医嘱项目")
    @PostMapping("/update")
    public ResponseWrapper update(@RequestBody BasDictType basDictType) {

        basDictTypeService.update(basDictType);
        return ResponseWrapper.Success();
    }
}
